package com.dd.logistics.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.logistics.entity.SupplierProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SupplierProductMapper extends BaseMapper<SupplierProduct> {
    
    @Select("SELECT sp.* FROM supplier_product sp ${ew.customSqlSegment}")
    List<SupplierProduct> selectProductsWithName(@Param(Constants.WRAPPER) Wrapper<SupplierProduct> wrapper);
    
    @Select("SELECT sp.* FROM supplier_product sp ${ew.customSqlSegment}")
    Page<SupplierProduct> selectPageWithName(Page<SupplierProduct> page, @Param(Constants.WRAPPER) Wrapper<SupplierProduct> wrapper);
    
    @Select("SELECT COUNT(*) FROM supplier_product sp ${ew.customSqlSegment}")
    Long selectJoinCount(@Param(Constants.WRAPPER) Wrapper<SupplierProduct> wrapper);
    
    @Select("SELECT sp.* FROM supplier_product sp WHERE sp.id = #{id}")
    SupplierProduct selectByIdWithProduct(@Param("id") Long id);
    
    @Select("SELECT COUNT(*) FROM supplier_product sp WHERE sp.supplier_id = #{supplierId}")
    Long countBySupplier(@Param("supplierId") Long supplierId);
} 